package teachersocket2

import java.io.{ObjectInputStream, ObjectOutputStream}
import java.net.Socket

object MyNodeManager {
  def main(args: Array[String]): Unit = {
    val socket = new Socket("127.0.0.1",8888)


    val outputStream = new ObjectOutputStream( socket.getOutputStream)

    val inputStream = new ObjectInputStream( socket.getInputStream)

    outputStream.writeObject(RegisterMsg("malaoshi","malaoshi123"))
    outputStream.flush()

    //接收服务端传送来的消息
    val resultMsg = inputStream.readObject()
    println(" 我是客户端，我接收到了服务端传送过来的消息" + resultMsg)

    //向服务端发送心跳
    outputStream.writeObject(HeatBeart("hadoop1"))
    outputStream.flush()


    //接收服务端传送来的消息
    val resultMsg2 = inputStream.readObject()
    println(" 我是客户端，我接收到了服务端传送过来心跳的结果" + resultMsg2)


    outputStream.close()
    inputStream.close()
    socket.close()


  }
}
